package com.mk.common.util;

import org.junit.Test;

public class MathDemo
{
	//将小数部分一律向整数部分进位
	@Test
	public void test1() {
		//向上取整
		System.out.println( Math.ceil(12.342323) );//13.0
		System.out.println( Math.ceil(-12.342323) );//-12.0
		System.out.println( Math.ceil(12.9821) );//13.0
		System.out.println( Math.ceil(-12.9238) );//-12.0
		System.out.println( Math.ceil(-12.00) );//-12.0
		System.out.println( Math.ceil(2.00) );//2.0
	}
	
	//一律舍去，仅保留整数
	@Test
	public void test2() {
		System.out.println( Math.floor(12.2) ); //12.0
		System.out.println( Math.floor(12.7) ); //12.0
		System.out.println( Math.floor(12.0) ); //12.0
	}
	
	//进行四舍五入 
	@Test
	public void test3() {
		System.out.println( Math.round(12.2) ); //12
		System.out.println( Math.round(12.7) ); //13
		System.out.println( Math.round(12.0) ); //12
	}
	
}
